
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
check if a string is a valid ssb-reference, also parses addresses
var ref = require('ssb-ref')
//check if a string is a link (sigil ++ base64, 44 chars ++ algo tag)
ref.isLink('%Lihvp+fMdt5CihjbOY6eZc0qCe0eKsrN2wfgXV2E3PM=.sha25s')
//check if a string is a feed id
ref.isFeed('@nUtgCIpqOsv6k5mnWKA4JeJVkJTd9Oz2gmv6rojQeXU=.ed25519')
//check if a string is a message id
ref.isMsg('%MPB9vxHO0pvi2ve2wh6Do05ZrV7P6ZjUQ+IEYnzLfTs=.sha256')
//check if a string is a blob id
ref.isBlob('&Pe5kTo/V/w4MToasp1IuyMrMcCkQwDOdyzbyD5fy4ac=.sha256')
//extract a ref out of a url
ref.extract('http://localhost:7777/#/msg/%pGzeEydYdHjKW1iIchR0Yumydsr3QSp8+FuYcwVwi8Q=.sha256?foo=bar')
== '%pGzeEydYdHjKW1iIchR0Yumydsr3QSp8+FuYcwVwi8Q=.sha256'
//url-encoding is supported
ref.extract('http://localhost:7777/#/msg/%25pGzeEydYdHjKW1iIchR0Yumydsr3QSp8%2BFuYcwVwi8Q%3D.sha256?foo=bar')
== '%pGzeEydYdHjKW1iIchR0Yumydsr3QSp8+FuYcwVwi8Q=.sha256'
returns true if string
is a either a feed, message, or blob reference.
it may also include a query string at the end.
returns true if string
is a feed id, a message id or a blob id,
respectively. id must not have a query string.
Aliases: isFeedId
, isMsgId
, isCloakedMsgId
, isBlobId
A generalisation of isFeed
, isMsg
, isBlob
.
Where e.g.
where suffix
is any non-empty string made up of: digits, letters, and -
Same is true for isMsgType, isBlobType
return true is a link, but may also have a query string.
removes punctuation to make a standard channel name
returns true if string
is a multiserver address,
or a legacy address, or if object
is a parsed legacy address
(with {host, port, key}
properties).
returns a feed id of the address in this key.
(assumes there is a shs:
protocol in the address,
including accepts future version of shs).
returns undefined
if it fails to parse a key.
returns true if invite
is a valid invite, either legacy or
multiserver style.
if string is one of the formats understood by ssb-ref, then
return the name of the type. otherwise return false.
output may be "feed", "msg", "blob", "address", "invite"
or false
.
if string
contains a ref, return just the ref,
ignoring anything else.
convert a legacy address object to a valid multiserver address.
note, because toLegacyAddress
may throw away portions of the
multiserver address, toMultiServerAddress(toLegacyAddress(addr))
might not equal addr
convert a multiserver address to a legacy address object.
return the components of a legacy invite, same output
as parseInvite
return the components of a multiserver invite, same output
as parseInvite
returns an object of data in the invite, returning {invite,remote,key,redirect}
.
note, the invite
in the output is the invite as a multiserver
address.
takes a multiserver address and returns {host,port,key}
if it is a websockets address, ws:
is included in host,
or wss:
if it's a secure websocket.
MIT
FAQs
test wether a string is a valid ssb reference type
The npm package ssb-ref receives a total of 241 weekly downloads. As such, ssb-ref popularity was classified as not popular.
We found that ssb-ref demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.